import moment from 'moment'

// 常量
export const API_CODE = {
  SUCCESS: 'success',
  AUTH_ERROR: 1005, //认证错误
  AUTH_INVALID: 1006 //认证错误
}

export const STORAGE = {
  USERNAME: 'USERNAME',
  ROLE_ID: 'ROLE_ID',
  API_TOKEN: 'API_TOKEN',
  LAST_IP: 'LAST_IP'
}
/**
 * 格式化时间
 * @param timestamp
 * @param format YYYY-MM-DD HH:mm:ss
 * @returns {string}
 */
export const dateFormatter = (timestamp, format = 'YYYY-MM-DD HH:mm:ss') => {
  if (!timestamp) {
    return '-'
  }
  return moment(timestamp * 1000).format(format)
}

/**
 * 获取提现状态
 * @param timestamp
 * @returns {string}
 */
export const cashStatus = pstatus => {
  if (pstatus == -1) {
    return '未通过,金币返回失败'
  }

  if (pstatus == -2) {
    return '提现失败'
  }
  return OPTIONSCASH[pstatus]
}
